package com.dnjn.happiness.system.api.factory;

import com.dnjn.happiness.common.core.domain.R;
import com.dnjn.happiness.system.api.RemoteConfigService;
import com.dnjn.happiness.system.api.RemoteRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteConfigFallbackFactory implements FallbackFactory<RemoteConfigService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteConfigFallbackFactory.class);
    @Override
    public RemoteConfigService create(Throwable throwable) {
        log.error("调用配置服务失败: " + throwable.getMessage());
        return new RemoteConfigService() {
            @Override
            public R<String> getThresholdDateaApi(String source) {
                return R.fail("查询快乐值监控临界值失败：{}" + throwable.getMessage());
            }


            @Override
            public R<String> configKeyApi(String configKey, String source) {
                return R.fail("查询配置信息失败：{}" + throwable.getMessage());
            }
        };
    }
}
